#pragma once
/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework Class Library
 * Version 2.00
 * 
 * Server Enumerator Class
 *      Provides methods for enumerating the server types on the local network.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
#include "stdafx.h"

using namespace System;
using namespace System::Net;
using namespace System::Collections;
using namespace System::Collections::Specialized;
using namespace System::Runtime::InteropServices;

namespace Adaptive
{
	namespace Win32
	{
		namespace Network
		{
			/// <summary>
			/// Represents and manages a network drive.
			/// </summary>
			public ref class NetworkDrive : public DisposableObjectBase
			{
			public:
				/*--------------------------------------------------------------------------------
				 * Constructor / Dispose / Destructor Methods
				 *------------------------------------------------------------------------------*/
				#pragma region Constructor / Dispose / Destructor Methods
				/// <summary>
				/// Initializes a new instance of the class.
				/// </summary>
				/// <remarks>
				/// This is the default constructor.
				/// </remarks>
				NetworkDrive();
				/// <summary>
				/// Initializes a new instance of the class to the specified values.
				/// </summary>
				/// <param name="localLetter">The local drive letter to assign to the share.</param>
				/// <param name="shareName">The name of the network share to connect to.</param>
				NetworkDrive(String^ localLetter, String^ shareName);
				/// <summary>
				/// Deallocates internally allocated objects.
				/// </summary>
				~NetworkDrive();				
				#pragma endregion

				/*--------------------------------------------------------------------------------
				 * Public Properties
				 *------------------------------------------------------------------------------*/
				#pragma region Public Properties
				/// <summary>
				/// Gets or sets a value indicating whether to force connection if drive is already mapped or
				/// force disconnection if the network is not responding.
				/// </summary>
				/// <value>
				/// <b>true</b> to force the state of the connection; otherwise, <b>false</b>.
				/// </value>
				property bool ForceConnection { bool get(); void set(bool value); }
				/// <summary>
				/// Gets or sets the local drive letter to use when mapping the drive.
				/// </summary>
				/// <value>
				/// A local drive letter value.
				/// </value>
				property String^ LocalDriveLetter { String^ get(); void set(String^ value); }
				/// <summary>
				/// Gets or sets a value indicating whether the share is to be re-established
				/// when the computer reboots.
				/// </summary>
				/// <value>
				/// <b>true</b> to establish a persistent share; otherwise, <b>false</b>.
				/// </value>
				property bool PersistentConnection { bool get(); void set(bool value); }
				/// <summary>
				/// Gets or sets a value indicating whether to prompt for user credentials when
				/// re-connecting a network drive.
				/// </summary>
				/// <value>
				/// <b>true</b> to prompt the user for credentials; otherwise, <b>false</b>.
				/// </value>
				property bool PromptForCredentials { bool get(); void set(bool value); }
				/// <summary>
				/// Gets or sets a value indicating whether the credentials are to be saved.
				/// </summary>
				/// <value>
				/// <b>true</b> to save the login credentials; otherwise, <b>false</b>.
				/// </value>
				property bool SaveCredentials { bool get(); void set(bool value); }
				/// <summary>
				/// Gets or sets the name of the network share to be mapped to a local drive.
				/// </summary>
				/// <value>
				/// The name of the network share to connect to.
				/// </value>
				property String^ ShareName { String^ get(); void set(String^ value); }
				#pragma endregion

				/*--------------------------------------------------------------------------------
				 * Public Methods / Functions
				 *------------------------------------------------------------------------------*/
				#pragma region Public Methods / Functions
				/// <summary>
				/// Attempts to map the drive using the specified credentials.
				/// </summary>
				/// <param name="userId">The Windows login name to use.</param>
				/// <param name="password">The Windows account password to use.</param>
				void MapDrive(String^ userId, String^ password);
				/// <summary>
				/// Unmaps the network drive.
				/// </summary>
				/// <param name="force">
				/// A value indicating whether the disconnect is to be forced.
				/// </param>
				void UnMapDrive(bool force);
				/// <summary>
				/// Attempts to restore a network connection.
				/// </summary>
				void RestoreDrive();
				#pragma endregion

			private:
				/// <summary>
				/// Default local drive letter.
				/// </summary>
				static String^ DEFAULT_LOCAL = "S";
				bool _saveCredentials;
				bool _persistent;
				bool _forceConnection;
				bool _promptForCredentials;
				String^ _localDriveLetter;
				String^ _shareName;
			};
		}
	}
}

